<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
</head>

<body>
    <label id="label1"></label>
</body>
<script type="text/javascript">
    function getTimeNow() {
        var label = document.getElementById('label1');
        var ajax = new XMLHttpRequest();
        ajax.open('GET', 'http://poetry.apiopen.top/getTime');
        ajax.send();
        ajax.onreadystatechange = function() {
            if (ajax.status == 200 && ajax.readyState == 4) {
                var obj = JSON.parse(ajax.responseText);
                console.log(obj.result);
                label.innerText =
                    JSON.stringify(obj.code) + '\n' +
                    JSON.stringify(obj.message) + '\n' +
                    JSON.stringify(obj.result.date) + '\n' +
                    JSON.stringify(obj.result.time) + '\n' +
                    JSON.stringify(obj.result.weekday) + '\n' +
                    JSON.stringify(obj.result.dateTime);
            }
        }
    }

    function getWangYiNews() {
        var label = document.getElementById('label1');
        var ajax = new XMLHttpRequest();
        ajax.open('POST', 'https://api.apiopen.top/getWangYiNews');
        ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        ajax.send('page=2&count=5');
        ajax.onreadystatechange = function() {
            if (ajax.status == 200 && ajax.readyState == 4) {
                var obj = JSON.parse(ajax.responseText);
                console.log(obj.result);
                label.innerHTML = `<a href="` + obj.result[0].path + `">` + obj.result[0].title + `</a>` + `<br/>` + obj.result[0].passtime;
            }
        }
    }

    function getUserComment() {
        var label = document.getElementById('label1');
        var ajax = new XMLHttpRequest();
        ajax.open('POST', 'https://api.apiopen.top/userFeedback');
        ajax.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        ajax.send('apikey=9648872f9aa08da137ce45fe1dda8279&text=我觉得应该再增加个版本更新功能。&email=135@qq.com');
        ajax.onreadystatechange = function() {
            if (ajax.status == 200 && ajax.readyState == 4) {
                var obj = JSON.parse(ajax.responseText);
                console.log(obj);
            }
        }
    }
    onload = function() {
        getUserComment();
        // getWangYiNews();
        //testpost();
    }
</script>

</html>